package game.windows;

import game.shared.Constants;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class ToggleButton extends Button{

	public ToggleButton(int functionCode, TextureRegion tButtonNomal, TextureRegion tButtonPressed) {
		super(functionCode, tButtonNomal, tButtonPressed);
	}
	
	@Override
	public void update() {
		if(isOver())
		{
			newLeftClick = Gdx.input.isButtonPressed(Buttons.LEFT);
			if(newLeftClick == true && oldLeftClick == false)
			{
				pressed = !pressed;
				Constants.set_RETURN_VALUE(pressed == true ? 1 : 0); 
				Constants.set_RETURN_CODE(functionCode);
			}
		}
		oldLeftClick = newLeftClick;
	}
}
